package com.maket.scxx.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.maket.scxx.domain.JcxmChecklist;
import com.maket.scxx.service.IJcxmChecklistService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 检查项目Controller
 * 
 * @author ruoyi
 * @date 2024-06-25
 */
@RestController
@RequestMapping("/checklist")
public class JcxmChecklistController extends BaseController
{
    @Autowired
    private IJcxmChecklistService jcxmChecklistService;

    /**
     * 查询检查项目列表
     */
    @RequiresPermissions("scxx:checklist:list")
    @GetMapping("/list")
    public TableDataInfo list(JcxmChecklist jcxmChecklist)
    {
        startPage();
        List<JcxmChecklist> list = jcxmChecklistService.selectJcxmChecklistList(jcxmChecklist);
        return getDataTable(list);
    }

    /**
     * 导出检查项目列表
     */
    @RequiresPermissions("scxx:checklist:export")
    @Log(title = "检查项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcxmChecklist jcxmChecklist)
    {
        List<JcxmChecklist> list = jcxmChecklistService.selectJcxmChecklistList(jcxmChecklist);
        ExcelUtil<JcxmChecklist> util = new ExcelUtil<JcxmChecklist>(JcxmChecklist.class);
        util.exportExcel(response, list, "检查项目数据");
    }

    /**
     * 获取检查项目详细信息
     */
    @RequiresPermissions("scxx:checklist:query")
    @GetMapping(value = "/{jcCode}")
    public AjaxResult getInfo(@PathVariable("jcCode") String jcCode)
    {
        return success(jcxmChecklistService.selectJcxmChecklistByJcCode(jcCode));
    }

    /**
     * 新增检查项目
     */
    @RequiresPermissions("scxx:checklist:add")
    @Log(title = "检查项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcxmChecklist jcxmChecklist)
    {
        return toAjax(jcxmChecklistService.insertJcxmChecklist(jcxmChecklist));
    }

    /**
     * 修改检查项目
     */
    @RequiresPermissions("scxx:checklist:edit")
    @Log(title = "检查项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcxmChecklist jcxmChecklist)
    {
        return toAjax(jcxmChecklistService.updateJcxmChecklist(jcxmChecklist));
    }

    /**
     * 删除检查项目
     */
    @RequiresPermissions("scxx:checklist:remove")
    @Log(title = "检查项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{jcCodes}")
    public AjaxResult remove(@PathVariable String[] jcCodes)
    {
        return toAjax(jcxmChecklistService.deleteJcxmChecklistByJcCodes(jcCodes));
    }
}
